package com.mutual.assistance.user.mq.listener;

import com.mutual.assistance.user.model.bo.UserMessageBO;
import com.mutual.assistance.user.constant.MqConstant;
import com.mutual.assistance.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author chenyuxin
 * @version 1.0
 * @description RabbitMQ监听消息
 * @date 2023/4/29 21:16
 */
@Component
@Slf4j
public class SpringRabbitListener {

    @Resource
    private UserService userService;

    @RabbitListener(queues = MqConstant.USER_QUEUE)
    public void listenFanoutQueue(UserMessageBO message) {
        log.info("消费者接收到到fanout.queue1的消息: " + message);
        userService.createUserMessage(message);
    }


}
